# coding: utf-8
import sys

from PySide6.QtWidgets import QWidget, QApplication, QScrollArea
from qfluentwidgets import IconWidget, FlowLayout, SingleDirectionScrollArea, ToolTipFilter

from qelwidgets import ElIcon


class Demo(SingleDirectionScrollArea):
    def __init__(self):
        super().__init__()
        self.view = QWidget()
        self.flowLayout = FlowLayout(self.view)
        self.flowLayout.setContentsMargins(20, 20, 20, 20)
        self.flowLayout.setHorizontalSpacing(20)
        self.flowLayout.setVerticalSpacing(20)
        self.__initWidgets()
        self.__initIcons()

    def __initWidgets(self):
        self.setWidget(self.view)
        self.setWidgetResizable(True)
        self.view.setAutoFillBackground(True)
        self.enableTransparentBackground()
        self.resize(1000, 600)

    def __initIcons(self):
        for icon in ElIcon:
            widget = IconWidget(icon, self.view)
            widget.installEventFilter(ToolTipFilter(widget))
            widget.setFixedSize(50, 50)
            widget.setToolTip(str(icon))
            self.flowLayout.addWidget(widget)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    demo = Demo()
    demo.setStyleSheet('background-color: #ffffff;')
    demo.show()
    sys.exit(app.exec())
